﻿@using ZoomLa.Model
@using ZoomLa.BLL
@using ZoomLa.Common
@model ZoomLa.SQLDAL.SQL.PageSetting
@{
    B_Comment cmtBll = new B_Comment();
    int ItemID = DataConverter.CLng(Request.QueryString["ID"]);
    M_Node nodeMod=ViewBag.nodeMod;
    M_UserInfo mu=ViewBag.mu;
    Layout = "~/Views/Shared/_empty.cshtml";
}
@section head{
<link rel="stylesheet" href="/App_Themes/V3.css" />
<style type="text/css">
.commentfor_body .comment_list { padding-bottom:0px;}
.emotion_ifr { position: absolute; overflow: hidden; margin-top: 30px; left: 30%; width: 700px; height: 380px; border: none; z-index: 1000; }
</style>
<script src="/JS/Controls/Emotion.js"></script>
<script>
var InsertSmiley = function (data) {var $text = $(emotion.param);$text.val($text.val() + data.title);}
</script> 
<title>发表评论</title>  
}
@section content{
 <div class="commentfor_body">
    <div style="position: relative;">
        <div id="Comment">
            <div id="Comment_List">
                @if (nodeMod.CommentType.Equals("0"))
                {
                    <div class="alert alert-info" id="nocoment" role="alert">
                        信息所属栏目评论功能已关闭
                    </div>
                }
                else if (nodeMod.CommentType.Equals("2") && mu.IsNull)
                {
                    <div class="alert alert-info" id="nologin" role="alert">
                        您必须登录才能评论，请点击<a href="javascript:;" onclick="LoginUser()">登录</a>
                    </div>
                }
                else //游客或有权限评论
                {
                    <div id="comentyes">
                        <div class="panel panel-default">
                            <div class="panel-heading">
                                <div class="gray_c">评论还可以输入<span id="maxcount_span">320</span>字</div>
                            </div>
                            <div class="CommentPK" style="display: none;">
                                @MVCHelper.H_Radios("RBLPK","我支持,我反对".Split(','),"1,0".Split(','),"1")
                            </div>
                            <textarea id="content_sender" name="content_sender" onkeyup="upMaxLength()" style="height: 120px;border:none;" maxlength="320" placeholder="我也来说两句" class="form-control msgtext"></textarea>
                            <div class="panel-footer">
                                <div class="hidden">
                                    <span>评 分：</span><span>
                                        <select class="form-control td_m" ID="DDLScore" name="DDLScore">
                                            <option value="1">1分</option>
                                            <option value="2">2分</option>
                                            <option value="3" selected="selected">3分</option>
                                            <option value="4">4分</option>
                                            <option value="5">5分</option>
                                        </select>
                                    </span>
                                </div>
                                <input type="text" ID="VCodesender" name="VCodesender" placeholder="验证码" MaxLength="6" class="form-control td_m" />
                                <img id="VCodesender_img" title="点击刷新验证码" class="code" style="height: 32px;" />
                                <input type="hidden" id="VCodesender_hid" name="VCodesender_hid" />
                                <div class="pull-right text-right" style="width: 40%;">
                                    <a href="javascript:;" title="选择表情" onclick="emotion.open(this,'#content_sender');" style="margin-right:10px;position:relative;bottom:-5px;"><i class="fa fa-smile-o" style="font-size: 30px"></i></a>
                                    <span id="reinfo_sender"></span>
                                    <button type="button" id="comment_sender" class="btn btn-primary" onclick="replyContent('sender')">发表评论</button>
                                </div>
                            </div>
                        </div>
                    </div>
                }
            </div>
            <div id="CommentInput" style="margin-bottom: 10px; position: relative;">
                <div class="alert alert-warning" role="alert">本评论只代表网友个人观点，不代表本站观点</div>
                <div class="panel panel-default comment_list">
                    <div class="panel-heading">
                        <ul>
                            <li>评论总数：@Model.itemCount</li>
                        </ul>
                    </div>
                    <ul class="list-group" style="width: 100%; padding: 0;">
                        @Html.Partial("CommentFor_List", Model)
                    </ul>
                </div>
                <div class="Assis_Div">
                    <a class="info" id="setup" title="顶" href="javascript:;" onclick="ContentAssist(1)">
                        <i class="fa fa-thumbs-o-up"></i>
                        <span class="gray_9 info_count" id="asscount">@cmtBll.GetUpCount(ItemID, 1)</span>
                    </a>
                    <a class="info" id="setdown" title="踩" href="javascript:;" onclick="ContentAssist(-1)">
                        <i class="fa fa-thumbs-o-down"></i>
                        <span class="gray_9 info_count">
                            @cmtBll.GetUpCount(ItemID, -1)
                        </span>
                    </a>
                </div>
            </div>
        </div>
    </div>
    <div id="boxCovers" style="display: none; position: absolute; top: 0px; left: 0px; z-index: 98; background: #b2b2b2;"></div>
    <div id="popupLogin" style="width: 300px; height: 200px; background: #fff; position: absolute; top: 250px; left: 350px; z-index: 99; border: #33ccff solid 3px; display: none;">
        <div id="LoginHead" class="ptitle"><span class="pspanl">用户登录</span><span id="lclose" class="pspanr">关闭</span></div>
    </div>
    <div id="toComment_box" class="hidden">
        <div id="toComment">
            <textarea id="content_reply" name="content_reply" class="form-control msgtext" placeholder="请输入评论内容" rows="4"></textarea>
            <span class="pull-left reply_vaild">
                <input type="text" ID="VCodereply" name="VCodereply" MaxLength="6" class="td_m margint5" placeholder="验证码" />
                <img id="VCodereply_img" title="点击刷新验证码" class="code" />
                <input type="hidden" id="VCodereply_hid" name="VCodereply_hid" />
            </span>
            <input type="hidden" name="txtpid" id="txtpid" />
            <span>
                <span id="reinfo_reply"></span>
                <a href="javascript:;" title="选择表情" onclick="emotion.open(this,'#content_reply');" style="margin-right:10px;position:relative;bottom:-5px;"><i class="fa fa-smile-o" style="font-size: 20px"></i></a>
                <button class="btn btn-sm btn-default" type="button" id="comment_reply" onclick="replyContent('reply')">发布</button>
            </span>
            <div class="clearfix"></div>
        </div>
    </div>
</div>   
    }
@section script{
<script src="/JS/ICMS/ZL_Common.js"></script>
<script src="/JS/Controls/ZL_Dialog.js"></script>
<script src="/JS/ZL_ValidateCode.js"></script>
<script src="/JS/Controls/ZL_Array.js"></script>
<script src="/JS/Modal/APIResult.js"></script>
<script>
    var apiUrl = "@MVCHelper.GetAction("Comment_API",Request)";
    var ismove = false;
    $(function () {
        $("#VCodesender").ValidateCode();
        $("#VCodesender").keydown(function () {
            if (event.keyCode == 13) {
                $("#comment_sender").click();
                return false;
            }
        });
        if (parent && parent.initCommInfo) { parent.initCommInfo($(".Assis_Div").html()); }
    })
    function LoginUser() {
        var url = parent.location.href.replace(location.protocol + "//", "").replace(location.host, "");
        parent.location.href = "/user/login?ReturnUrl=" + url;
    }
    //支持反对操作
    function Support(obj) {
        $.post(apiUrl, { action: 'support', id: $(obj).data('id'), flag: $(obj).data('flag'), gid: '@ItemID' }, function (data) {
            if (data == "-1") { alert("不能重复支持或反对!"); return; }
            $(obj).parent().find('.support').addClass('gray_9');
            var val = parseInt($(obj).find(".count").text()) + 1;
            if (isNaN(val)) { val = 1; }
            $(obj).find(".count").text(val);
            $(obj).parent().find('.support').removeAttr("onclick");
        });
    }
    //回复操作
    function replyContent(action) {
        $("#comment_" + action).attr("disabled", "disabled");
        $("#reinfo_" + action).html("<span class='fa fa-refresh fa-spin'></span>");
        var postData = { "action": action, id: $("#txtpid").val(), content: $("#content_" + action).val(), VCode_hid: $("#VCode" + action + "_hid").val(), VCode: $("#VCode" + action).val() };
        $.post(apiUrl, postData, function (data) {
            switch (data) {
                case "2":
                    location = location;
                    break;
                case "1":
                    $("#reinfo_" + action).html("<span class='comm_audited'><span class='fa fa-check-circle'></span> 感谢回复,编辑正在审核中</span>");
                    $("#VCode" + action).ValidateCode();
                    $("#VCode" + action).removeClass('codeok');
                    $("#VCode" + action).val('');
                    $("#content_" + action).val('');
                    location = location;
                    break;
                case "-1":
                    $("#reinfo_" + action).html("<span style='color:red;'><span class='fa fa-exclamation-circle'></span> 验证码不正确!</span>");
                    $("#comment_" + action).removeAttr('disabled');
                    break;
                case "-2":
                    $("#reinfo_" + action).html("未登录!点击[<a href='javascript:;' onclick='parent.checkLogin()'>登录</a>]!");
                    break;
                case "-3":
                    $("#reinfo_" + action).html("内容不能为空!");
                    $("#comment_" + action).removeAttr('disabled');
                    break;
                case "-5":
                    $("#reinfo_" + action).html("您已经评论过了!");
                    break;
                case "-4":
                default:
                    $("#reinfo_" + action).html("<span style='color:red;'>该内容不允许发表评论!</span>");
                    $("#comment_" + action).removeAttr('disabled');
                    break;
            }
        })
    }
    //举报操作
    function Report(obj) {
        $.post(apiUrl, { action: "report", cid: $(obj).data('cid') }, function (data) {
            if (data == "1") {
                $(obj).removeAttr('onclick');
                $(obj).addClass('gray_9');
                $(obj).text('已举报');
            }
        })
    }
    //顶与踩
    function ContentAssist(flag) {
        var idflag = flag == 1 ? "setup" : "setdown";
        $.post(apiUrl, { action: 'assist', gid: "@ItemID", value: flag }, function (data) {
            $("#" + idflag).removeAttr("onclick");
            $("#" + idflag).find(".hand").addClass("gray_c");
            if (data == "1") {
                $(".info").css({ color: '#666', });
                var val = parseInt($("#" + idflag).find(".info_count").text()) + 1;
                if (isNaN(val)) { val = 1; }
                $("#" + idflag).find(".info_count").text(val);
            }

            parent.initCommInfo($(".Assis_Div").html());
        })
    }
    //回复框
    function showHuiFu(obj, pid) {
        $("#comment_reply").removeAttr("disabled");
        $("#reinfo_reply").html("");
        $("#VCodereply").ValidateCode();
        $("#txtpid").val(pid);
        $("#toComment").appendTo($(obj).parent());
    }
    function LoginSuccess() {
        history.go(0);
    }
    //统计评论数量
    function upMaxLength() {
        $("#maxcount_span").text(320 - $("#content_sender").val().length);
    }
</script>  
    
    }